//
//  CZTitleButton.m
//  小和微博
//
//  Created by 董晓合 on 15/2/21.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "CZTitleButton.h"

@implementation CZTitleButton

// 通过代码创建控件时会调用
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}



// 通过xib/Storboard创建时调用
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup
{
//    设置颜色
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    设置图片居中
    self.imageView.contentMode = UIViewContentModeCenter;
//   设置标题居中
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.titleLabel.x = self.imageView.x;
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) + 5;

}


@end
